#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i;
    int j = 0;
    int seed = 1000;
    int numPlayer = 2;
    int maxBonus = 10;
    int p, r, handCount, handPos;
    int bonus;
    int k[10] = {adventurer, council_room, feast, gardens, mine,
                remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 50;
    //mine is enum 11
    int mine[MAX_HAND];

    printf ("TESTING Mine():\n");
        for (handCount = 1; handCount <= 4; handCount++)
        {
            for (int ch1 = -1; ch1 < 28; ++ ch1){

#if (NOISY_TEST == 1)
                printf("Mine: Test player 0 with %d cards before discard\n", handCount);
#endif
                memset(&G, 23, sizeof(struct gameState));   // clear the game state
                r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
                G.handCount[p] = handCount;                 // set the number of cards on hand
                memcpy(G.hand[p], mine, sizeof(int) * handCount); // set all the cards to mine
                int returned = mineCard(ch1, ch1, &G, 0); 
                
#if (NOISY_TEST == 1)
                printf("Mine: G.handCount = %d, returned= %d\n", numHandCards(&G), returned);
#endif
                assert(returned == -1 || returned == 0); // check if the return is correct
#if (NOISY_TEST == 1)
                printf("Effect: Test player 0 with %d cards before discard\n", handCount);
#endif
                memset(&G, 23, sizeof(struct gameState));   // clear the game state
                r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
                G.handCount[p] = handCount;                 // set the number of cards on hand
                memcpy(G.hand[p], mine, sizeof(int) * handCount); // set all the cards to mine
                cardEffect(13, ch1, ch1, 0, &G, 0, 0);

#if (NOISY_TEST == 1)
                printf("Effect: G.handCount = %d, returned= %d\n", numHandCards(&G), returned);
#endif
                assert(returned == -1 || returned == 0);// check if the return is correct
            }
        }

    printf("All tests passed!\n");

    return 0;
}
